from django.urls import path, register_converter

from apps.users.views import UsernameCountView, RegisterView, LoginView, LogoutView, UserInfoView, SaveEmailView, \
    EmailVerifyView, AddressCreateView, AddressView
from utils.converters import UsernameConverter

# 注册用户名验证的转换器  别名叫uname
register_converter(UsernameConverter, 'uname')

urlpatterns = [
    # 使用uname转换器验证用户名
    path('usernames/<uname:username>/count/', UsernameCountView.as_view()),
    path('register/', RegisterView.as_view()),
    path('login/', LoginView.as_view()),
    path('logout/', LogoutView.as_view()),
    path('info/', UserInfoView.as_view()),
    path('emails/', SaveEmailView.as_view()),
    path('emails/verification/', EmailVerifyView.as_view()),
    path('addresses/create/', AddressCreateView.as_view()),
    path('addresses/', AddressView.as_view()),
]
